home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 04 - 1988 / 04.05 May 88 / Basic sources / Drawing Count.MSBAS < prev    next >
Encoding:
Text File  |  1988-03-03  |  2.2 KB  |  84 lines  |  [TEXT/MSBB]

  1. ' Drawing Count Program
  2. ' Converts Drawing Log Data created by FileMaker Plus
  3. ' and computes total number of drawings under each date
  4. ' By Dave Kelly
  5. ' ©1988
  6.  
  7. DIM Charge$(1000),Date1(1000),Date2(1000),Date3(1000),Date4(1000)
  8. DIM tCharge$(20),tDate1(20),tDate2(20),tDate3(20),tDate4(20)
  9. filename$=FILES$(1,"TEXT")
  10. IF filename$="" THEN END
  11. OPEN "I",1,filename$
  12. OPEN "O",2,"Drawing Count.DATA"
  13. PRINT
  14. count=0
  15. CALL MOVETO(10,30)
  16. PRINT "Now Reading in Records..."
  17. WHILE NOT EOF(1)
  18.     count=count+1
  19.     CALL MOVETO (10,50)
  20.     PRINT count
  21.     Charge$(count)=""
  22.     i$=""
  23.     A$=""
  24.     C$=""
  25.     S$=""
  26.     INPUT#1,Charge$(count),i$,A$,C$,S$
  27.     IF LEN(Charge$(count))>0 THEN
  28.         IF RIGHT$(Charge$(count),1)=")" THEN
  29.             Charge$(count)=MID$(Charge$(count),LEN(Charge$(count))-4,4)
  30.         ELSE
  31.             Charge$(count)=RIGHT$(Charge$(count),4)
  32.         END IF
  33.     END IF
  34.     IF LEN(i$)>0 THEN Date1(count)=1 ELSE Date1(count)=0
  35.     IF LEN(A$)>0 THEN Date2(count)=1 ELSE Date2(count)=0
  36.     IF LEN(C$)>0 THEN Date3(count)=1 ELSE Date3(count)=0
  37.     IF LEN(S$)>0 THEN Date4(count)=1 ELSE Date4(count)=0
  38. WEND
  39. CALL MOVETO(10,70)
  40. PRINT "Now Sorting Data..."
  41. CALL Sort(count,Charge$(),Date1(),Date2(),Date3(),Date4())
  42. k=0
  43. FOR j=1 TO count
  44. IF tCharge$(k)<>Charge$(j) THEN k=k+1
  45. tCharge$(k)=Charge$(j)
  46. tDate1(k)=tDate1(k)+Date1(j)
  47. tDate2(k)=tDate2(k)+Date2(j)
  48. tDate3(k)=tDate3(k)+Date3(j)
  49. tDate4(k)=tDate4(k)+Date4(j)
  50. NEXT j
  51. CALL MOVETO(10,90)
  52. PRINT "Now Writing to File..."
  53. PRINT#2,"Charge#    Date1    Date2    Date3    Date4"
  54. FOR i=1 TO k
  55. tDate1(i)=tDate1(i)-tDate2(i)
  56. tDate2(i)=tDate2(i)-tDate3(i)
  57. tDate3(i)=tDate3(i)-tDate4(i)
  58. PRINT #2,tCharge$(i),tDate1(i),tDate2(i),tDate3(i),tDate4(i)
  59. PRINT tCharge$(i),tDate1(i),tDate2(i),tDate3(i),tDate4(i)
  60. NEXT i
  61. CLOSE #1
  62. CLOSE #2
  63. PRINT"Click to continue..."
  64. WHILE MOUSE(0)<>1:WEND
  65. END
  66.  
  67. SUB Sort(count,Charge$(),Date1(),Date2(),Date3(),Date4()) STATIC
  68.     flips=1
  69.     WHILE flips
  70.         flips=0
  71.         FOR i=2 TO count
  72.             IF Charge$(i-1)> Charge$(i) THEN
  73.                 flips=1
  74.                 SWAP Charge$(i-1),Charge$(i)
  75.                 SWAP Date1(i-1),Date1(i)
  76.                 SWAP Date2(i-1),Date2(i)
  77.                 SWAP Date3(i-1),Date3(i)
  78.                 SWAP Date4(i-1),Date4(i)
  79.             END IF
  80.         NEXT
  81.     WEND
  82. END SUB
  83.  
  84.